home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / unix / cracklib25_small_tar.z / cracklib25_small_tar / cracklib25_small / README < prev   
Encoding:
Text File  |  1993-07-09  |  8.8 KB  |  301 lines

  1. CrackLib:    A ProActive Password Sanity Library
  2.  
  3. By:         Alec Muffett, 16th June, 1993
  4.  
  5. Address:    alec.muffett@uk.sun.com
  6.         alec.muffett@sun.co.uk
  7.         alec_muffett@hicom.lut.ac.uk
  8.  
  9.  
  10. - This software is not my fault in any way, nor indeed anybody's -
  11.  
  12.  
  13. *** What is CrackLib ***
  14.  
  15.  
  16. CrackLib is a library containing a C function (well, lots of functions
  17. really, but you only need to use one of them) which may be used in a
  18. "passwd"-like program.
  19.  
  20. The idea is simple: try to prevent users from choosing passwords that
  21. could be guessed by "Crack" by filtering them out, at source.
  22.  
  23. CrackLib is an offshoot of the the version 5 "Crack" software, and
  24. contains a considerable number of ideas nicked from the new software.
  25.  
  26. At the time of writing, Crack 5 is incomplete (still awaiting purchase
  27. of my home box) - but I though I could share this with you.
  28.  
  29. [ Incidentally, if Dell or anyone would like to "donate" a Linuxable
  30. 486DX2-66MHz box (EISA/16Mb RAM/640MB HD/AHA1740) as a development
  31. platform for Crack, I'd be more than grateful to hear from you.  8-) ]
  32.  
  33.  
  34. NOTE THIS WELL: CrackLib is NOT a replacement "passwd" program.
  35. CrackLib is a LIBRARY.  CrackLib is what trendy marketdroid types would
  36. probably call an "enabler".
  37.  
  38. The idea is that you wire it into your _own_ "passwd" program (if you
  39. have source); alternatively, you wire it into something like "shadow"
  40. from off of the net.  You can use it in other things, too.
  41.  
  42. You can use it almost _everywhere_.
  43.  
  44.  
  45. *** Advantages of CrackLib ***
  46.  
  47.  
  48. 1) it WORKS!
  49.  
  50. I wrote something similar ("goodpass") a few years back, which went out
  51. with Crack v3.x.
  52.  
  53. Goodpass was slow and buggy and I think it was used (at least in part)
  54. in "npasswd".  Hopefully, CrackLib will supplant "goodpass" entirely.
  55.  
  56.  
  57. 2) it's FAST!
  58.  
  59. CrackLib finds potential passwords quickly, by using an index file to
  60. access dictionary words, and by keeping a table to assist binary
  61. searching.
  62.  
  63.  
  64. 3) it's SMALL!
  65.  
  66. CrackLib's dictionary is modified-DAWG compressed with a chunksize of 16
  67. words (see Crack v5.0 docs (when it comes out) for details) - and then
  68. the index file is built, with one entry per chunk.
  69.  
  70. The upshot of all this is that CrackLib can do indexed, binary searches
  71. in a 1.4 million word dictionary (raw size ~ 15Mb), but the CrackLib
  72. files (data+index+watermarks) occupy only ~ 7Mb.  (45% original size)
  73.  
  74. It's even efficient over NFS !
  75.  
  76.  
  77. 4) it's MIND-NUMBINGLY THOROUGH!
  78.  
  79. (is this beginning to read like a B-movie flyer, or what?)
  80.  
  81. CrackLib makes literally hundreds of tests to determine whether you've
  82. chosen a bad password.
  83.  
  84. * It tries to generate words from your username and gecos entry to tries
  85. to match them against what you've chosen.
  86.  
  87. * It checks for simplistic patterns.
  88.  
  89. * It then tries to reverse-engineer your password into a dictionary
  90. word, and searches for it in your dictionary.
  91.  
  92. - after all that, it's PROBABLY a safe(-ish) password.  8-)
  93.  
  94.  
  95. *** Instructions for building CrackLib...
  96.  
  97.  
  98. STEP 0) Engage your brain.
  99.  
  100. I'm interested in improving the CrackLib software, doing bugfixes,
  101. "guessing technique" improvements, and portability enhancements. 
  102.  
  103. I'm NOT interested in unhelpful comments like "well, _my_ operating
  104. system doesn't come with a dictionary".  If it doesn't, either complain
  105. to your vendor, or GO AND GET a dictionary off the net. 
  106.  
  107. CrackLib is NOT a TOOL.  It is not a complete package.  It is not
  108. something you can utilise directly. 
  109.  
  110. It is a resource, an aid, something to enhance the functionality of
  111. other software.  You need to (either) write OR modify other software to
  112. use it.  If you can't do this, then you shouldn't be wasting your time
  113. with it. 
  114.  
  115. Regarding bugs and portability problems: please try to work them out for
  116. yourself, and then (please) TELL me about them.  This will help me
  117. improve future versions. 
  118.  
  119.  
  120. STEP 1) Edit the Makefile to set your preferred value of DICTPATH
  121.  
  122. This it the directory+filename-prefix that your version of CrackLib will
  123. go hunting for, and it must be visible to all programs on all hosts that
  124. use CrackLib
  125.  
  126. Hence, if you want to use a CrackLib binary on a distributed network,
  127. these files are probably best placed on an NFS server.
  128.  
  129. Note: You have to specify a FILENAME PREFIX too, eg:
  130.  
  131.     DICTPATH=/usr/local/lib/pw_dict
  132.  
  133. which will generate:
  134.  
  135.     /usr/local/lib/pw_dict.pwd
  136.     /usr/local/lib/pw_dict.pwi
  137.     /usr/local/lib/pw_dict.hwm
  138.  
  139. which are the files that CrackLib needs.
  140.  
  141. These files are NOT byte-order independent, in fact they are probably
  142. ARCHITECTURE SPECIFIC, mostly due to speed constraints.  If this is a
  143. problem, I suggest you use:
  144.  
  145.     DICTPATH=/usr/local/lib/pw_dict.sun4
  146.     DICTPATH=/usr/local/lib/pw_dict.i386
  147.     DICTPATH=/usr/local/lib/pw_dict.cray
  148.  
  149. ...etc, and build several sets of files, as appropriate.
  150.  
  151.  
  152. (Hackers Note: Strictly, only *.pwi and *.hwm should be architecture
  153. dependent; however, if you build two dictionaries on two different
  154. platforms, you MAY wind up with different *.pwd files too, due to
  155. incompatibilities in the std Unix utilities, or from using different
  156. SOURCEDICTs.
  157.  
  158. I may try to work this out in the next release.  In the mean time, if
  159. your *.pwd files are EXACTLY identical (use "cmp" to test), you can
  160. delete the multiple copies and use softlinks instead.)
  161.  
  162.  
  163. STEP 2) Add to the SOURCEDICT variable, any files continaing extra words
  164. that you wish CrackLib to use.  CrackLib merges all of these files
  165. together, removes redundant characters, and compresses them.  Generally,
  166. the output file is 40..60% the size of all the input files, combined.
  167.  
  168. NOTE: THE DEFAULT VALUE OF "SOURCEDICT" CONTAINS "/usr/dict/words" -
  169. this is a file which can be found on many BSD-type Unix systems,
  170. containing a list of words, one per line, suitable for use with
  171. "cracklib".  If you do not have such a file, refer to STEP 0.
  172.  
  173.  
  174. STEP 3) do:
  175.  
  176.     % make all
  177.  
  178. then do:
  179.  
  180.     % make install
  181.  
  182. which will build the CrackLib dictionary in $DICTPATH.
  183.  
  184.  
  185. *** NOTE THIS WELL ***
  186.  
  187. If you supply massive amounts of text to CrackLib to use a a dictionary,
  188. you must have enough free space available for use by the "sort" command,
  189. when the dictionary is built.
  190.  
  191. So: If you do not have (say) about 20Mb free in /usr/tmp (or whatever
  192. temporary area your "sort" command uses), have a look at the
  193. "util/mkdict" script.
  194.  
  195. You can usually tweak the "sort" command to use any large area of disk
  196. you desire, by use of the "-T" option, and "mkdict" has a hook for this.
  197.  
  198.  
  199. STEP 4) Wire a call to "FascistCheck()" into your "passwd" program
  200.  
  201.  
  202. - Left as an exercise for the reader.
  203.  
  204.  
  205. *** Example of how to invoke CrackLib
  206.  
  207. Insert a call to the routine FascistCheck, which is defined thusly:
  208.  
  209. NAME
  210.     FascistCheck - check a potential password for guessability
  211.  
  212.  
  213. SYNOPSIS
  214.  
  215.     char *FascistCheck(char *pw, char *dictpath);
  216.  
  217.  
  218. DESCRIPTION
  219.  
  220.     FascistCheck() takes 2 arguments:
  221.  
  222.     pw - a string continaing the users chosen "potential password"
  223.  
  224.     dictpath - the full path name + filename prefix of the
  225.     CrackLib dictionary, specified in the installation Makefile.
  226.     (If you still haven't sussed, I'm talking about DICTPATH).
  227.  
  228.  
  229. RETURN VALUE
  230.  
  231.     FascistCheck() returns the NULL pointer for a good password,
  232.     or a pointer to a diagnostic string if it is a bad password.
  233.  
  234.  
  235. BUGS
  236.     - it can't catch everything. Just most things.
  237.  
  238.     - it calls getpwuid(getuid()) to look up the user,
  239.       this MAY affect poorly written programs
  240.  
  241.     - using more than one pw_dict file, eg:
  242.  
  243.         char *msg;
  244.         if (msg = FascistCheck(pw, "onepath") ||
  245.             msg = FascistCheck(pw, "anotherpath"))
  246.         {
  247.             printf("Bad Password: because %s\n", msg);
  248.         }
  249.  
  250.        ...works, but it's a kludge. AVOID IT IF POSSIBLE.
  251.        Using just the one dictionary is more efficient, anyway.
  252.  
  253.     - PWOpen() routines should cope with having more than 1
  254.       dictionary open at a time.  I'll fix this RSN.
  255.  
  256.  
  257. WORKED EXAMPLE
  258.  
  259. ---- modified extract from BSD distribution - "local_passwd.c" ----
  260.  
  261. #ifndef CRACKLIB_DICTPATH /* if possible, get from the same Makefile as CrackLib */
  262. #define CRACKLIB_DICTPATH "/usr/local/lib/pw_dict"
  263. #endif        /* see examples on how to import DICTPATH into CRACKLIB_DICTPATH */
  264. ...
  265. ...
  266. ...
  267.     for (buf[0] = '\0', tries = 0;;) {
  268.         p = getpass("New password:");
  269.         if (!*p) {
  270.             (void)printf("Password unchanged.\n");
  271.             pw_error(NULL, 0, 0);
  272.         }
  273.  
  274. #ifndef CRACKLIB_DICTPATH
  275.         if (strlen(p) <= 5 && (uid != 0 || ++tries < 2)) {
  276.             (void)printf("Please enter a longer password.\n");
  277.             continue;
  278.         }
  279.         for (t = p; *t && islower(*t); ++t);
  280.         if (!*t && (uid != 0 || ++tries < 2)) {
  281.             (void)printf("Please don't use an all-lower case password.\nUnusual capitalization, control characters or digits are suggested.\n");
  282.             continue;
  283.         }
  284. #else
  285.         {
  286.             char *msg;
  287.             if (msg = (char *) FascistCheck(pwbuf, CRACKLIB_DICTPATH)) {
  288.                 printf("Please use a different password.\n");
  289.                 printf("The one you have chosen is unsuitable because %s.\n", msg);
  290.                 continue;    /* go round and round until they get it right */
  291.             }
  292.         }
  293. #endif /* CRACKLIB_DICTPATH */
  294.  
  295.         (void)strcpy(buf, p);
  296.         if (!strcmp(buf, getpass("Retype new password:")))
  297.             break;
  298.         (void)printf("Mismatch; try again, EOF to quit.\n");
  299.     }
  300. ---- end of extract ----
  301.